import request from '@/utils/request'
import { CHECC_API_CMS } from '@/constants/proxy'

export function fetchListRequest(params) {
  const { current } = params;
  return request({
    url: CHECC_API_CMS + `/job/page`,
    method: 'post',
    params: { current },
    data: params,
  })
}

export function createRecord(data) {
  return request({
    url: CHECC_API_CMS + '/job',
    method: 'post',
    data,
  })
}

export function editRecord(data) {
  return request({
    url: CHECC_API_CMS + '/job',
    method: 'put',
    data,
  })
}

export function deleteRecord(id) {
  return request({
    url: CHECC_API_CMS + `/job/${id}`,
    method: 'delete',
  })
}

// 根据机构查询岗位信息
export function positionByDept(ids) {
  return request({
    url: CHECC_API_CMS + `/job/orgs`,
    method: 'post',
    data: {
      orgids: ids,
    }
  })
}

// 获取机构数据
export function fetchOrgTree() {
  return request({
    url: CHECC_API_CMS + `/org/tree`,
    method: 'get'
  })
}

// 获取机构数据
export function fetchMoveOrgTree() {
  return request({
    url: CHECC_API_CMS + `/org/getSubTreeById`,
    method: 'get'
  })
}

// 获取机构数据
export function getOrgTree() {
  return request({
    url: CHECC_API_CMS + `/org/tree`,
    // url: CHECC_API_CMS + `/org/getSysOrgList`,
    method: 'get'
  })
}